﻿using System.Threading.Tasks;
using EventBusTest.Shared;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.EventBus.Distributed;

namespace EventBusTest.ApiHost.Controllers
{
    [Route("api")]
    [ApiController]
    public class PublisherController:ControllerBase
    {
        private readonly IDistributedEventBus _distributedEventBus;

        public PublisherController(IDistributedEventBus distributedEventBus)
        {
            this._distributedEventBus = distributedEventBus;
        }

        [HttpPost]
        public async Task TestPublish()
        {
            var obj = new TestPublishEto { 
                Id = 1,
                Name = "Haha"
            };
            await this._distributedEventBus.PublishAsync(obj);
        }
    }
}
